﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Device.Location;

namespace Outdoors.Helpers.Flickr
{
    public static class FlickrAPI
    {
        private static string[] Licenses = { "4", "5", "6", "7" };
        private static string License { get; set; }
        private static string Key { get; set; }

        public static void Initialize()
        {
            string[] licenses = { "4", "5", "6", "7" };
            string license = String.Join(",", licenses);

            License = license.Replace(",", "%2C");

            Key = "fa9dd0b9f1dda200c4e6f78bf1b4cb83";
        }

        public static string PhotosSearchUrl(GeoCoordinate mapCenter)
        {
            Initialize();

            string url = "https://api.flickr.com/services/rest/" +
                "?method=flickr.photos.search" +
                "&license={0}" +
                "&api_key={1}" +
                "&lat={2}" +
                "&lon={3}" +
                "&radius=1" +
                "&format=json" +
                "&nojsoncallback=1";

            string baseUrl = string.Format(url, License, Key, mapCenter.Latitude, mapCenter.Longitude);

            return baseUrl;
        }
    }
}
